<script>
    function submitLogin(){
        if($("#userID").val() == ""){
            $("#userID").addClass("is-invalid");
            return;
        }
        if($("#key").val() == ""){
            $("#key").addClass("is-invalid");
            return;
        } 
        $.ajax({
            type: 'POST',
            url: '/submit/form/login',
            data: $("form").serialize(),
            success: function(resJson){
                if(resJson.success){
                    window.localStorage.setItem('xjtu-idle-token', resJson.data.body);
                    window.alert('登录成功');
                    window.location.href = '/myhome'
                }else{
                    window.alert('登录失败, 请检查NetID/密码');
                }
            }
        })
    }
</script>
